<?php
/**
 * Created by PhpStorm.
 * User: peter
 * Date: 2018/10/19
 * Time: 下午12:00
 */

namespace app\model;


use think\model\concern\SoftDelete;

class ActivityOrder extends Base
{
    protected $pk = 'id';
    // 此处表名请务必设置为public
    public $table = 'activity_order';
    protected $autoWriteTimestamp = true; //自动时间戳
    protected $createTime  = 'create_at';
    protected $updateTime  = 'update_at';
    // 软删除
    use SoftDelete;
    protected $deleteTime = 'delete_at';
    protected $defaultSoftDelete = 0;

    /**
     * @purpose 绑定附表模型
     * @return \think\model\relation\HasMany
     */
    public function attach () {
        return $this->hasMany('ActivityOrderAttach','order_id', 'id');
    }

    /**
     * @purpose 绑定活动模型
     * @return \think\model\relation\HasOne
     */
    public function activity () {
        return $this->hasOne('Activity', 'id', 'activity_id');
    }
    /**
     * @purpose 绑定团期模型
     * @return \think\model\relation\HasOne
     */
    public function groupStage () {
        return $this->hasOne('ActivityGroupStage', 'id', 'group_stage_id');
    }

    /**
     * @purpose 关联用户模型
     * @return \think\model\relation\HasOne
     */
    public function member () {
        return $this->hasOne('Member', 'uid', 'uid');
    }
}